package com.huobao.yunying.fragments;

import java.io.Serializable;
import java.util.List;

import org.xutils.common.util.LogUtil;

import com.huobao.yunying.entity.Detailprops;
import com.huobao.zhangying.R;
import com.mcoy.snapscrollview.McoyScrollView;

import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.TableLayout;
import android.widget.TextView;

public class Tuwen_shuxing_Fragment extends BaseFragment {

	private Handler handler = new Handler();
	private List<Detailprops> props;
	private String description;
	public McoyScrollView scrollView;
//	public Tuwen_shuxing_Fragment(List<Detailprops> list, String description){
//		this.props = list;
//		this.description = description;
//	}
	public static Tuwen_shuxing_Fragment getInstant(List<Detailprops> list,String description){
		Tuwen_shuxing_Fragment instance = new Tuwen_shuxing_Fragment();
		Bundle args = new Bundle();
		args.putSerializable("data",(Serializable) list);
		args.putString("description",description);
		instance.setArguments(args);
		return instance;
	}
	@Override
	public View onCreateContentView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.layout_shuxing, null);
		this.props = (List<Detailprops>)getArguments().getSerializable("data");
		this.description = getArguments().getString("description");
		scrollView = (McoyScrollView)view.findViewById(R.id.scrollview);
		TableLayout layout = (TableLayout) view.findViewById(R.id.tablayout);
		WebView webView = (WebView) view.findViewById(R.id.touchwebview);
		webView.getSettings().setJavaScriptEnabled(true);
		webView.getSettings().setUseWideViewPort(true);
		webView.getSettings().setLoadWithOverviewMode(true);
		LogUtil.e(description);
		webView.loadDataWithBaseURL("", description,"text/html", "utf-8", null);
		for(Detailprops detailprops : props){
			View itemView = inflater.inflate(R.layout.item_tabrow, null);
			TextView tv_key = (TextView) itemView.findViewById(R.id.tv_key);
			TextView tv_value = (TextView) itemView.findViewById(R.id.tv_value);
			tv_key.setText(detailprops.name);
			tv_value.setText(detailprops.value);
			layout.addView(itemView);
		}
		handler.post(new Runnable() {
			
			@Override
			public void run() {
				showContentView();
			}
		});
		return view;
	}
}
